﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using MS.InformationManagement.Presenter.SearchRefinementPanel;

namespace MS.InformationManagement.Controls._CONTROLTEMPLATES.InformationManagerControls
{
    public partial class SearchHistoryTemplate : UserControl, ISearchHistoryTemplate
    {
        private MS.InformationManagement.DAL.DocumentCenter.Search.Enums.SearchType _SearchType;
        private DateTime? _SearchDate;

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void hplSimpleSearchCriteria_Click(object sender, EventArgs e)
        {
            OnFilterClick(this,
                new FilterClickEventArgs
                {
                    Filter = new DAL.DocumentCenter.SearchConfig
                    {
                        SearchType = SearchType,
                        SimpleSearchCriteria = SimpleSearchCriteria
                    }
                });
        }

        #region [ISearchHistoryTemplate members]
        public DAL.DocumentCenter.HistorialDeBusqueda SearchHistory
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public DateTime? SearchDate
        {
            get { return _SearchDate; }
            set
            {
                _SearchDate = value;
                ltrlSearchDate.Text = _SearchDate.Value.ToString("dddd dd \\de MMMM, a la(\\s) hh:mm:ss ");
            }
        }

        public string SimpleSearchCriteria
        {
            get
            {
                return hplSimpleSearchCriteria.Text;
            }
            set
            {
                hplSimpleSearchCriteria.Text = value;
            }
        }

        public MS.InformationManagement.DAL.DocumentCenter.Search.Enums.SearchType SearchType
        {
            get { return _SearchType; }
            set
            {
                _SearchType = value;
                switch (value)
                {
                    case DAL.DocumentCenter.Search.Enums.SearchType.Simple:
                        plhFullSearchData.Visible = false;
                        plhSimpleSearchData.Visible = true;
                        break;
                    case DAL.DocumentCenter.Search.Enums.SearchType.Advanced:
                        plhFullSearchData.Visible = true;
                        plhSimpleSearchData.Visible = false;
                        break;
                }
            }
        }

        public MS.InformationManagement.DAL.DocumentCenter.Search.AdvancedSearchConfig[] AdvancedSearchCriteria
        {
            get;
            set;
        }

        public DAL.DocumentCenter.SearchConfig SearchConfig
        {
            get;
            set;
        }
        #endregion

        public delegate void FilterClickHandler(object sender, FilterClickEventArgs e);
        public event FilterClickHandler OnFilterClick;




    }
}
